<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery.min.js"></script>
</head>
<body>
    <button onclick="gogo()" >发ajax请求</button>
    <table id="info" border="1"></table>
</body>
<script>
    var path="http://localhost:8081/CG/json";
    function gogo(){
        console.log("发送"+path);
        $.ajax({
            url:path,
            type:"GET",
            dataType:"json",
            success:function (result){
                console.log(result);
                show(result);//生成表格
            },
            error:function (){
                $("#info").html("请求失败")
            }
        });
    }
    function show(data){
        var tb=document.querySelector("table");
        for(i=1;i<data.length;i++){
            var tr=tb.insertRow();//新建行
            var td=tr.insertCell();
            td.innerText=data[i].userName;
            var td1=tr.insertCell();
            td1.innerText=data[i].passWord;
            var td2=tr.insertCell();
            td2.innerText=data[i].sex;
        }
    }
</script>
</html>